Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract the querystring logic into separate module: #1600

Merged
merged 3 commits into from May 28, 2015

Conversation

simov
Copy link
Member

@simov simov commented May 25, 2015

  • Update qs to version 3.0.0 with support for rfc3986 encoding
  • Use request's rfc3986 only when using the querystring module
  • Add test branch for rfc3986 encoding tests using querystring
  • Support for eq, sep and options arguments for querystring
    parse and stringify methods via option keys

I was waiting for this PR ljharb/qs#76 to get in to refactor the rfc3986 logic in request. Then this bug report #1593 came out, so this PR is fixing both issues.

At first I tried using querystring.escape for rfc3986 encoding in querystring.stringify

this.lib.escape = function (str) {return this.rfc3986(str)}.bind(this)

But that would affect the global namespace so I opted out for standard wrapping.

Next I had to export the querystring.unescape out of the Querystring module

Querystring.prototype.unescape = querystring.unescape

because it's used in two places in request.js Quick check on the node's code revealed this:

QueryString.unescape = function(s, decodeSpaces) {
  try {
    return decodeURIComponent(s);
  } catch (e) {
    return QueryString.unescapeBuffer(s, decodeSpaces).toString();
  }
};

So probably we can use directly decodeURIComponent in our context, but then again I chose the safer option.

@limbo-lab now you can pass the sep, eq and options arguments to the querystring module like this:

qsStringifyOptions:{sep:';', eq:':', options:{...}}

Let me know what do you think, as there no tests for this behavior yet, and it's not documented in the readme.

Fixes #1593

simov added 3 commits May 25, 2015 21:41
- Update `qs` to version 3.0.0 with support for rfc3986 encoding
- Use request's rfc3986 only when using the `querystring` module
- Add test branch for rfc3986 encoding tests using `querystring`
- Support for `eq`, `sep` and `options` arguments for `querystring`
  `parse` and `stringify` methods via option keys
simov added a commit that referenced this pull request May 28, 2015
Extract the querystring logic into separate module
@simov simov merged commit 6a3fbb7 into request:master May 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qsStringifyOptions is not correctly forwarded to querystring.stringify
1 participant